<?php
/**
 * @author Oliver Leisalu
 * @package WapBilling
 */
abstract class WapBillingOperator {
	
	private $configFilePath;
	
	protected $lastError;
	
	public function __construct( $configFilePath = NULL ) {
		
		$this->configFilePath = $configFilePath ? $configFilePath : DOM_CONF_DIR_PATH . 'wapBilling.conf.php';
		
		if( !file_exists( $this->configFilePath ) )
			trigger_error('Config file is not found. Expected path: <strong>'.$this->configFilePath.'</strong>', E_USER_ERROR );
			
		require( $this->configFilePath );
		
		$key = strtolower(substr( get_class($this), 11  ));
		if( !isset($WAP_BILLING[$key]) )
			trigger_error('WapBilling configuration for '.$key.' doesn\'t exist!', E_USER_ERROR);
		
		foreach( $WAP_BILLING[$key] as $key => $value  ) 
			$this->$key = $value;
	}
	
	/**
	 * Returns phonenumber in format 372xxxxxxx
	 * @return String
	 */
	abstract public function getMsisdn();
	
	/**
	 * Sends payment request
	 *
	 * @param Float $price
	 * @param String $description
	 * @return Int [0-success, 1 -failure, 2-not allowed, 3-system error]
	 */
	abstract public function pay( $price, $description, $uid = 0, $logId );
	
	public function getLastError() {
		return $this->lastError;
	}
	
}
?>